home *** CD-ROM | disk | FTP | other *** search
- cseg segment para public 'code'
- org 100h
- motor proc far
-
- intaddr equ 1ch*4 ; timer interrupt address
- usraddr equ 63h*4 ; point to first copy of program
- whozat equ 1236H ; program signature
- mcount equ 440h ; motor timeout count - BIOS data
- mstate equ 4ffh ; motor state - in DOS comm area
-
- ; Memory-resident program to keep the disk drive motor running. Once
- ; started, the drive motor will run indefinitely until another drive is
- ; referenced or this program is run again.
-
- assume cs:cseg,ds:cseg,ss:nothing,es:nothing
- jmp p050 ; transient code
-
- signature dw whozat ; program signature
- jumpval dd 0 ; continuation of timer interrupt
-
- p000: ; interrupt code
- push ax ; save registers
- push ds
- push si
- mov ax,0
- mov ds,ax
- mov si,mstate ; point to motor state
- mov al,[si]
- cmp al,0
- jz p010 ; don't keep it running
- mov si,mcount ; point to time out counter
- mov ax,37 ; timeout count - 2 seconds
- mov [si],ax ; update timeout
- p010: pop si ; restore registers
- pop ds
- pop ax
- jmp cs:[jumpval]
-
- p050: ; start of transient code
- mov dx,offset copyr
- call p200 ; print copyright message
- mov ax,0
- mov es,ax
- mov di,usraddr+2
- mov ax,es:[di] ; get prior segment
- mov es,ax
- mov di,offset signature
- mov cx,es:[di] ; get program's signature
- cmp cx,whozat ; is it this program?
- jnz p075 ; no - install it
-
- mov di,mstate ; yes - modify state
- mov ax,0
- mov es,ax
- mov al,es:[di] ; get state
- xor al,0ffh ; invert al
- mov es:[di],al
- mov dx,offset msg1
- call p200
- cmp al,0 ; motor off?
- jz p060 ; yes
- mov dx,offset msg1on
- jmp p070
- p060: mov dx,offset msg1off
- p070: call p200
- int 20h ; terminate
-
- p075: mov ax,0
- mov es,ax
- mov di,intaddr ; interrupt location
- mov ax,es:[di] ; get ip of current interrupt
- mov bx,es:[di+2] ; get cs of current interrupt
- mov si,offset jumpval ; point to jump value
- mov [si],ax ; save
- mov [si+2],bx ; it
-
- p080: mov ax,0
- mov es,ax
- mov al,0ffh ; set motor on
- mov di,mstate
- mov es:[di],al
- mov di,intaddr
- mov ax,offset p000 ; get current ip
- mov bx,ds ; get current cs
-
- cli ; clear interrupts
- mov es:[di],ax ; modify
- mov es:[di+2],bx ; vector
- mov di,usraddr
- push cs
- pop bx ; get cs in bx
- mov es:[di+2],bx ; set segment pointer
- sti ; set interrupts
-
- mov dx,offset msg1 ; print message
- call p200
- mov dx,offset msg1on
- call p200
- mov dx,offset p050 ; last byte of resident portion
- int 27h ; terminate
-
- p200 proc near ; print message
- push ax
- mov ah,9
- int 21h
- pop ax
- ret
- p200 endp
-
- copyr db 'MOTOR - Copyright 1983 Data Base Decisions',10,13,'$'
- msg1 db 'Turning drive motor $'
- msg1on db 'on.$'
- msg1off db 'off.$'
- motor endp
- cseg ends
- end motor
-